package com.diankangwo.dao.impl;

import com.diankangwo.dao.LogisticsConfigurationDAO;
import com.diankangwo.domain.LogisticsConfiguration;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class LogisticsConfigurationDAOImpl extends BaseDaoImpl<LogisticsConfiguration> implements LogisticsConfigurationDAO {

    @Override
    public LogisticsConfiguration findByAddress(Integer id, Integer beForeProvinceId, Integer beForeCityId, Integer beForeDistrictId, Integer afterProvinceId, Integer afterCityId, Integer afterDistrictId) {
        List<LogisticsConfiguration> lcList = new ArrayList<LogisticsConfiguration>();
        lcList =  findByQuery("from LogisticsConfiguration lc where lc.C_Id = ? and beForeProvinceId = ? and beForeCityId = ? and beForeDistrictId = ? and aftereProvinceId =  ? and afterCityId = ? and afterDistrictId = ?", id, beForeProvinceId, beForeCityId, beForeDistrictId, afterProvinceId, afterCityId, afterDistrictId);
        if (lcList == null || lcList.size() ==0) {
            return null;
        }else{
            return lcList.get(0);
        }
    }

    @Override
    public List<LogisticsConfiguration> findByCID(Integer cid) {
        List<LogisticsConfiguration> lcList = new ArrayList<LogisticsConfiguration>();
        lcList =  findByQuery("from LogisticsConfiguration lc where lc.C_Id = ? ",cid);
        if (lcList == null || lcList.size() ==0) {
            return null;
        }else{
            return lcList;
        }
    }
}
